<?php
namespace Mp\Service\Widget;

use Mp\Service\Common\Asset;

class Notification extends Input{

	protected $label = 'notification';

	protected $position = [
		'align'=>'left', //left right center
		'from' => 'top',
	];

	protected $animation = [
		'in' => 'fadeIn',
		'out' => 'fadeInLeft',
	];

	protected $js = [
		'static/mp/assets/plugins/notification/js/bootstrap-growl.min.js'
	];

	protected $css = [];

	protected $script;

	protected $type = 'inverse'; //inverse info success warning danger


	protected $view = 'Mp::widgets.notification';

	protected function _init($params){
		Asset::js($this->js);
		$this->label = $params['label'] ?? $this->label;
		$this->position = $params['position'] ?? $this->size;
		$this->animation = $params['animation'] ?? $this->class;
		$this->script = <<<SCRIPT
		function notify(message, type){
        $.growl({
            message: message
        },{
            type: type,
            allow_dismiss: false,
            label: 'Cancel',
            className: 'btn-xs btn-inverse',
            placement: {
                from: 'bottom',
                align: 'right'
            },
            delay: 2500,
            animate: {
                    enter: 'animated fadeInRight',
                    exit: 'animated fadeOutRight'
            },
            offset: {
                x: 30,
                y: 30
            }
        });
    };

   
        notify('Welcome to Notification page', 'inverse');
SCRIPT;
		Asset::script($this->script);
		$this->data = [
			'label' => $this->label,
			'position' => $this->position,
			'animation' => $this->animation,

		];
	}
	
}